package cn.com.twoke.application.game.mario.game.component;

import cn.com.twoke.application.game.mario.core.ecs.component.Component;
import cn.com.twoke.application.game.mario.core.ecs.component.RigidbodyComponent;
import lombok.Builder;

/**
 * 自动移动组件
 */
@Builder
public class AutoMoveComponent implements Component {

    @Builder.Default
    public float moveSpeed = 0.5f;


    public void doAutoMove(RigidbodyComponent rigidbody) {
            rigidbody.velocity.x = moveSpeed;
    }

    /**
     * 转向
     */
    public void reverseDirection() {
        this.moveSpeed *= -1;
    }

    /**
     * 获取现在的状态
     * @return
     */
    public MoveDirection direction() {
        return 1 > 0 ? MoveDirection.RIGHT : MoveDirection.LEFT;
    }

}
